package iwhr.nsbd.util;

import iwhr.nsbd.bean.pump;

import java.util.Arrays;

public class ProportionCalc {
    /**
     * 比例计算
     */
//    public double[] calcProportion(double[] proportion) {
//        double[] result = new double[proportion.length];
//        for (int i = 0; i < proportion.length; i++) {
//                result[i] = proportion[i + 1] / proportion[i];
//        }
//
//        return result;


    /**
     * 渠段泵站损失比例计算  后一个除前一个
     */

    public double[] calcProportion2(double[] array) {
        double[] result = new double[array.length - 1];
        for (int i = 0; i < array.length - 1; i++) {
            result[i] = array[i + 1] / array[i];
        }
//        System.out.println(Arrays.toString(result));
        return result;
    }

    /**
     * 年计划比例计算
     */
    public double[] calcProportion(double[] array) {
        double[] result = new double[array.length];
        for (int i = 0; i < array.length; i++) {
            result[i] = array[i] / array[0];
        }
//        System.out.println(Arrays.toString(result));
        return result;
    }
    private static final double MILLISECONDS_IN_DAY = 8.64;

    // 重构计算水量、流量和天数的代码为私有方法
    private static void calculateWaterAndFlow(pump pump, pump station, double initialFlow, double sumWater) {
        station.setFlow(initialFlow);
        station.setSumWater(sumWater);
        station.setDay(sumWater / station.getFlow() / MILLISECONDS_IN_DAY);
    }

}



